

import 'package:flutter/material.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'local_notice_plug.dart';

class LocalNoticePage extends StatelessWidget {
  const LocalNoticePage({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('本地通知示例'),
        ),
        body: Center(
          child: ElevatedButton(
            onPressed: () async {
              const AndroidNotificationDetails androidPlatformChannelSpecifics =
              AndroidNotificationDetails(
                'your_channel_id',
                'your_channel_name',
                channelDescription: 'your_channel_description',
                importance: Importance.max,
                priority: Priority.high,
              );
              const NotificationDetails platformChannelSpecifics =
              NotificationDetails(
                android: androidPlatformChannelSpecifics,
                iOS: DarwinNotificationDetails(),
              );
              await flutterLocalNotificationsPlugin.show(
                0,
                '通知标题',
                '通知内容',
                platformChannelSpecifics,
                payload: 'item x',
              );
            },
            child: const Text('发送本地通知'),
          ),
        ),
      ),
    );
  }
}